<template>
  <!-- 确认购买区域 -->
  <div class="confirm">
    <!-- 总价钱 -->
    <div class="price">不含运费  合计:
      <span class="total">￥{{ amount }}</span>
    </div>
    <!-- 结算页面跳转按钮 -->
    <button class="btn" :class="count ? '' : 'btn_forbid'" @click="toOrderForm">去结算({{ count }})</button>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  name: 'CartConfirm',
  computed: {
    ...mapGetters(['amount', 'count'])
  },
  methods: {
    toOrderForm () {
      const islogin = this.$store.state.islogin
      if (this.count === 0) {
        return false
      } else {
        if (!islogin) {
          this.$router.push({
            path: '/login'
          })
        } else {
          this.$router.push({
            path: '/cart/order'
          })
        }
      }
    }
  }
}
</script>

<style lang="less" scoped>
// 确认购买区域
.confirm {
  position: fixed;
  display: flex;
  align-items: center;
  bottom: 2rem;
  width: 15rem;
  height: 2rem;
  line-height: 2rem;
  z-index: 99;
  background-color: #fff;
  // 总价钱
  .price {
    flex: 1;
    font-size: .56rem;
    color: #999;
    text-align: right;
    .total {
      font-size: .72rem;
      font-weight: 700;
      color: rgb(255, 20, 147);
    }
  }
  // 结算页面跳转按钮
  .btn {
    float: right;
    height: 1.5rem;
    font-size: .56rem;
    color: #fff;
    text-align: center;
    background: rgb(255, 20, 147);
    border-radius: .2rem;
    padding: 0 .4rem;
    margin: 0.1rem 0.3rem 0 0.2rem;
  }
}

.btn_forbid {
  background: #ccc!important;
}
</style>
